#include "MainFrame.h"
#include "Common.h"
//==================================================
IMPLEMENT_WNDPROC(BeeFrame)
//==================================================
DECLEAR_MSGFN(OnCreate)
DECLEAR_MSGFN(OnLButtonDown)
DECLEAR_MSGFN(OnMButtonDown)
DECLEAR_MSGFN(OnRButtonDown)
DECLEAR_MSGFN(OnKeyDown)
DECLEAR_MSGFN(OnKeyUp)
DECLEAR_MSGFN(OnPaint)
DECLEAR_MSGFN(OnDestroy)
DECLEAR_MSGFN(OnClose)
//==================================================
MSGMAP_BEG(BeeFrame)
MSGMAP_SET(WM_CREATE, &OnCreate)
MSGMAP_SET(WM_LBUTTONDOWN, &OnLButtonDown)
MSGMAP_SET(WM_MBUTTONDOWN, &OnMButtonDown)
MSGMAP_SET(WM_RBUTTONDOWN, &OnRButtonDown)
MSGMAP_SET(WM_PAINT, &OnPaint)
MSGMAP_SET(WM_KEYDOWN, &OnKeyDown)
MSGMAP_SET(WM_KEYUP, &OnKeyUp)
MSGMAP_SET(WM_DESTROY, &OnDestroy)
MSGMAP_SET(WM_CLOSE, &OnClose)
MSGMAP_SET(WM_NULL, NULL)
MSGMAP_END()
//==================================================
IMPLEMENT_MSGFN(OnCreate)
{
	PlaneCreate();
	StageSet();
	FightTimer(hWnd);

	return 0;
}
//==================================================
IMPLEMENT_MSGFN(OnLButtonDown)
{
	if(!g_Pause && !g_Die)
	{
		BulletCreate();
	}

	return 0;
}
//==================================================
IMPLEMENT_MSGFN(OnMButtonDown)
{
	g_Die = false;
	g_Stage = 1;
	g_Pause = false;
	g_AutoFire = false;
	
	PlaneClear();
	PlaneCreate();
	BulletClear();
	AttackClear();
	StageSet();

	InvalidateRect(hWnd, NULL, TRUE);

	return 0;
}
//==================================================
IMPLEMENT_MSGFN(OnRButtonDown)
{
	if(g_Stage<10)
	{
		g_Die = false;
		g_Pause = false;
		g_AutoFire = false;
		g_Stage++;

		PlaneClear();
		PlaneCreate();
		BulletClear();
		AttackClear();
		StageSet();

		InvalidateRect(hWnd, NULL, TRUE);
	}

	return 0;
}
//==================================================
IMPLEMENT_MSGFN(OnKeyDown)
{
	//TODO:
	int nKey = (int)wParam;
	ButtonDown(hWnd, nKey);
	//END TODO

	return 0;
}
//==================================================
IMPLEMENT_MSGFN(OnKeyUp)
{
	//TODO:
	int nKey = (int)wParam;
	ButtonUp(hWnd, nKey);
	//END TODO
	
	return 0;
}
//==================================================
IMPLEMENT_MSGFN(OnPaint)
{
	PAINTSTRUCT ps;
	HDC hdc = BeginPaint(hWnd, &ps);

	//TODO:
	DrawObject(hdc);
	//END TODO

	EndPaint(hWnd, &ps);

	return 0;
}
//==================================================
IMPLEMENT_MSGFN(OnDestroy)
{
	KillTimer(hWnd, 20);
	KillTimer(hWnd, 21);
	KillTimer(hWnd, 22);
	KillTimer(hWnd, 23);
	KillTimer(hWnd, 24);
	PostQuitMessage(0);

	return 0;
}
//==================================================
IMPLEMENT_MSGFN(OnClose)
{
	DestroyWindow(hWnd);

	return 0;
}
